<?php
function reequipment_adminapi_updatecompanyschedule($args)
{
    // Get arguments from argument array
    extract($args);

	// Handle the times.  When updating, date complete should be here, but not date added.
    $last_completed = time();
    // Get datbase setup
    $dbconn =& xarDBGetConn();
    $xartable =& xarDBGetTables();
    $table = $xartable['recompanyschedule'];

    $update = array();
    $bindvars = array();

    // Update item
    $query = "UPDATE $table SET ";
    
    if (isset($last_completed)){
        $update[] = "last_completed = ? ";
        $bind[] = $last_completed;
    }
    
    $query .= join(",",$update);
    
    if (!empty($schedule_id)) {
        $where[] = 'schedule_id = ?';
        $bind[] = (int)$schedule_id;
    }

    if (!empty($company_id)) {
        $where[] = 'company_id = ?';
        $bind[] = (int)$company_id;
    }
    
    if (!empty($equipment_id)) {
        $where[] = 'equipment_id = ?';
        $bind[] = (int)$equipment_id;
    }    

    if (!empty($where)) {
        $query .= ' WHERE ' . implode(' AND ', $where);
    }
    
    $result =& $dbconn->Execute($query, $bind);
    if (!$result) return;
    return true;
}
?>